-- card: 13104 from stack: in.6 -- bmap block id: 5804 -- flags: 2000 -- background id: 3411 -- name: Type 7 XCMD ----- HyperTalk script ----- on closeCard lock screen hide cd pict hide cd btn "OK" unlock screen pass closeCard end closeCard on showButtons show cd btn ID 1 show cd btn ID 2 end showButtons on turnOn hide cd pict pass turnOn end turnOn -- part 1 (button) -- low flags: 80 -- high flags: A003 -- rect: left=291 top=120 right=142 bottom=413 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Many Selections ----- HyperTalk script ----- on mouseUp put " Help Topics" into prompt ShowDialog 7,5002,prompt,geneva,9,cd fld "Test",5,"many" if line 1 of the result = 2 then put "You clicked the “Cancel” button." into bg fld "theResult" else if the number of items in line 2 of the result = 1 then put "You clicked on line" && line 2 of the result & "." into bg fld "theResult" else put "Hilited lines:" && line 2 of the result into bg fld "theResult" end if end mouseUp -- part 2 (button) -- low flags: 80 -- high flags: A003 -- rect: left=291 top=165 right=187 bottom=413 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: One Selection ----- HyperTalk script ----- on mouseUp put empty into bg fld "theResult" put "aramadillo" & return & "cockroach" & return & "doodoo" & return & "duck" & return & "flamingo" & return & "kangaroo" & return & "lobster" & return & "moose" & return & "penguin" & return & "shark" & return & "walrus" & return & "wart hog" & return into container put " Animals" into prompt put 1 into theItem repeat ShowDialog 7,5004,prompt,chicago,12,container,theItem,"one" put the result into theResult put line 2 of theResult into theItem if line 1 of theResult = 5 then ShowDialog 1,5000,"",FALSE exit repeat end if if line 1 of theResult = 2 then exit repeat ShowDialog 6,5003,3001,12,line 2 of theResult,FALSE put the result into theResult --••••••• Notes on Type 6 of ShowDialog ••••••• -- If the user clicked the TOPICS button (DITL item #7) the -- result will be TRUE. -- If the user clicked the CANCEL button (DITL item #1) the -- result will be FALSE. -- Use the TRUE/FALSE values to respond to the dialog (as in -- this example). if theResult is FALSE then exit repeat end repeat end mouseUp -- part 3 (field) -- low flags: 80 -- high flags: 2007 -- rect: left=164 top=19 right=278 bottom=481 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 3 -- text size: 10 -- style flags: 0 -- line height: 13 -- part name: test -- part 4 (button) -- low flags: 80 -- high flags: A003 -- rect: left=405 top=266 right=288 bottom=440 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: OK ----- HyperTalk script ----- on mouseUp lock screen hide me hide cd pict unlock screen with zoom in end mouseUp -- part 7 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=11 top=4 right=64 bottom=78 -- title width / last selected line: 0 -- icon id / first selected line: 529 / 529 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: SD -- part contents for background part 21 ----- text ----- ShowDialog XCMD Type 7 -- part contents for background part 30 ----- text ----- 19 -- part contents for background part 15 ----- text ----- ShowDialog Type 7 parameters are: ShowDialog 7,,, ,,, ,,[, ] where 7 is the type; is the ID of the DLOG resource; is a string of text that can appear in the dialog; is the font that the scrolling list will appear in; is the font size that the scrolling list will appear in; is a return delimited variable or field that will make up the scrolling list; is the line of the scrolling list that will be hilited when the dialog is shown. Pass "0" (that's a zero) if you want NO line initially hilited; configures the scrolling list so that only one line can be selected at at time. If this parameter is "one" then only one line can be selected. If it is "many" then Shift-clicking will select multiple lines and Shift-click-dragging will select "continuous" lines. This parameter must be in quotes in the parameter list. The last two parameters are OPTIONAL. They set the top, left coordinates of the dialog. If these two parameters are omitted the dialog will be centered within the card window. -- part contents for background part 17 ----- text ----- • Prompt String Font The will always appear in Chicago 12 pt. • Scrolling List Font If the font that you specify for the list isn't available, Chicago will be substituted. If (for some reason) you specify 0 as the point size, 12 pt will be substituted. • Regular Buttons ShowDialog Type 7 can have as many "regular" buttons as you want. ShowDialog will return the DITL item# of the button clicked as line 1 of the Result. If enter or return is typed, or the user double-clicks on a line in the scrolling field, line 1 of the result will contain the DITL item# of the default button (which is ALWAYS 1). If the user types command-period, line 1 of the result will ALWAYS contain DITL item# 2. • Static Text The Dialog Manager allows you to have ONLY ONE font in a dialog. Any static text that you put in your DLOG template will appear in the same font (and size) as the list (I got around this restriction with the prompt string by hard coding its font attributes). So if you wish to have static text in your dialog that is NOT in the same font as the list, make this text in a "paint" program and add it to the DLOG template as a PICT. • The DLOG/DITL Template In designing your DLOG/DITL template there are some things to keep in mind: DITL item #1 is the OK button. DITL item #2 is the CANCEL button. DITL item #3 is the scrolling list. This must be a ENABLED useritem. DITL item #4 is the prompt string. This MUST be a DISABLED useritem. If you don't want a prompt string, DITL item #4 can be anything else (Just pass "" in the parameter.) DITL items #5 ... onward can be regular buttons, icons, PICTs, and static text. • The Scrolling List DITL Item In constructing the useritem that will be the scrolling list: The list will have a vertical scroll bar which will lie OUTSIDE the useritem and will be 15 pixels wide. So leave a 15 pixel-wide space TO THE RIGHT of useritem DITL #3 for the scroll bar (otherwise the scroll bar could overlap with something else you have placed in the DLOG template). • Click here to see. • Just prior to displaying the dialog, ShowDialog calculates the line height of the list based on the ascent + decent + leading of the font that you have specified. In order for the list to be displayed correctly, the vertical height of useritem DITL #3 must be an EXACT MULTIPLE of the line height of the list. You don't have to worry about this yourself. ShowDialog takes a look at the dimensions of the useritem, and, if the vertical height is not EXACTLY a multiple of the line height, IT ADJUSTS THE VERTICAL HEIGHT OF THE USERITEM FOR YOU. So, if you find that the rect of DISPLAYED list is slightly different from the one that you specified in your DLOG template, it is because the useritem was a little off in its dimensions. In other words, when you design your DLOG template, put the useritem approximately where you want it and ShowDialog will position it correctly. The reason for all this is purely aesthetic. • Show me. • The result is a RETURN-delimited list: Line 1: DITL item# of button clicked. Line 2: comma-delimited list of lines from the scrolling list that were hilited: first hilited line, second hilited line, third hilited line, etc. If the user hits enter or return, or double-clicks on a line in the scrolling list, line 1 of the result will contain the DITL item# of the default button (which is ALWAYS 1). This is why DITL item# 1 should be OK. If the user types command-period, line 1 of the result will contain 2 (DITL item# 2). This is why DITL item# 2 should ALWAYS be CANCEL. The other "buttons" can be hot spots, if you like. Just put ENABLED useritems in your DLOG template. If you're going to associate these hot spots with a graphic in the dialog, remember that the hot spot useritems must lie "UNDER" the graphic PICT. See "All PICT Dialogs" under "Special Notes" on the Special Dialogs Card for details on how to do this. • Click here and go there now. • -- part contents for card part 3 ----- text ----- About ShowDialog Alert Types cicn's Color Icon Bars Debugging ShowDialog Dialog Types Making PICT's Obtaining ResEdit Other X-Commands:     Ants XFCN     ClipToPICT XCMD     ColorOn XFCN     PrintDocs XCMD PICT Maker Registration ResEdit Shareware ShowDialog Types:     Type 1     Type 2     Type 3     Type 4     Type 5     Type 6     Type 7 Special Dialogs Splash Screens Window Types -- part contents for background part 18 ----- text -----            ••••••••••••••••• If you've been using versions of ShowDialog older than 1.6, please note that the PARAMETERS AND RESULT for Type 7 have changed to increase its functionality. You can now configure the scrolling list so that only one line can be selected at a time. The result is now RETURN-delimited. Line 1 of the result is the DITL item# of the button clicked. Line 2 of the result is a comma-delimited list of the lines from the scrolling list that were hilited.            ••••••••••••••••• ShowDialog Type 7 displays a dialog that contains a scrolling list. Use this type of dialog in situations where the user must select from a list of items. Type 7 can contain icons, PICTs, static text, and any number of "regular" buttons in addition to the scrolling list. •Function of the Scrolling List The scrolling list can be configured so that only one line can be selected at a time, or can be configured so that Shift-clicking will select multiple lines and Shift-click-dragging will select "continuous" lines. Dragging the mouse above or below the list will scroll it in that direction. Double clicking on a line or hitting return or enter is the same as clicking the OK button. Typing command-period is the same as clicking the CANCEL button. The scrolling list is subject to full keyboard control and will respond to "hot keys": • To scroll the list up: press the cursor up button press the page up button press the "less than" (<) button (no need to shift) • To scroll the list down: press the cursor down button press the page down button press the "greater than" button (no need to shift) • To scroll list to the top: press the home button • To scroll list to the end: press the end button • To directly to a line ("hot keys"): The list will scroll to a line that begins with the     letter that you type. This function is only useful,     of course, if you alphabetize your list items. There is no limit to the number of lines that a list can contain. The more lines in the list, the longer it will take before the dialog is displayed. ShowDialog displays the watch cursor while it constructs the list (although this time is negligible for lists of any reasonable length).